<script>
    function changePage() {
        window.location.href = "/admin/api/logout.php?out=ture";
    }
    $.ajax({
        url: '/admin/api/loging.php', // API URL
        type: 'POST', // 请求类型
        success: function(response) {
            // 请求成功时的回调函数
            response = JSON.parse(response);
            if (response.data == 0) {
                document.getElementById("logout").style.display = "none";
                document.getElementById("goadmin").style.display = "none";
            } else if (response.data == 1) {
                document.getElementById("logi").style.display = "none";
                document.getElementById("usename").innerHTML = response.username;
                document.getElementById("usename").style.display = "";
            } else {
                document.getElementById("logout").style.display = "none";
                document.getElementById("goadmin").style.display = "none";
                document.getElementById("logi").style.display = "none";
                console.log("请求错误!");
            }
            console.log(response);
        },
        error: function(error) {
            console.log(error);
        }
    });
</script>